/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.proyecto;

import com.proyecto.datos.EntityAlumno;
import com.proyecto.datos.EntityCarrera;
import com.proyecto.datos.EntityConsultaIntro;
import com.proyecto.datos.EntityGrupo;
import com.proyecto.datos.EntityHorario;
import com.proyecto.datos.EntityHorarioLab;
import com.proyecto.datos.EntityMateria;
import com.proyecto.datos.EntityPlan;
import com.proyecto.modelado.Alumno;
import com.proyecto.modelado.Carrera;
import com.proyecto.modelado.DetalleAlumno;
import com.proyecto.modelado.DetalleHorarioLab;
import com.proyecto.modelado.Grupo;
import com.proyecto.modelado.Horario;
import com.proyecto.modelado.Materia;
import com.proyecto.modelado.Plan;
import java.util.ArrayList;
import javax.swing.DefaultComboBoxModel;
import javax.swing.DefaultListModel;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author mario
 */
public class frmEditarAlumnoIntroFisica extends javax.swing.JInternalFrame {

    DetalleAlumno detal;
    ArrayList arryTable;
    EntityCarrera entCarre;
    EntityGrupo entGrupo;
    EntityMateria entMate;
    EntityHorario entHora;
    ArrayList arryCarre;
    ArrayList arryGrupoLab;
    ArrayList arryGrupoMate;
    ArrayList arryMate;
    ArrayList arryHora;
    Horario hora;
    Materia mate;
    Grupo gru;
    Carrera carre;
    EntityAlumno entAl;
    ArrayList arryAl;
    Alumno al;
    EntityHorarioLab entHoraLab;
    ArrayList arryDetalab;
    DetalleHorarioLab detalab;
    
    Plan pla;
    EntityPlan entPla;
    int id_plan;
    int id_materia;

    //Metodo para tabla
    public void PopulatTabla(int id_materia) {

        DefaultTableModel tabla;
        Object[] fila = new Object[9];

        try {
            String[] columnName = {"ID", "Carnet", "Nombre", "Apellido", "Carrera", "Materia", "Grupo Clase", "Horario Lab", "Grupo Lab"};
            tabla = new DefaultTableModel(null, columnName);
            //populamos el arraylist de la tabla
            arryTable = new ArrayList();
            detal = new DetalleAlumno();
            EntityConsultaIntro entCon = new EntityConsultaIntro();
            arryTable = detal.MostrarAlumnos(id_materia);
            if (arryTable != null) {
                for (int i = 0; i < arryTable.size(); i++) {
                    entCon = (EntityConsultaIntro) arryTable.get(i);
                    fila[0] = entCon.getId_alumno();
                    fila[1] = entCon.getEntCarnet();
                    fila[2] = entCon.getEntnombre();
                    fila[3] = entCon.getEntApellido();
                    fila[4] = entCon.getEntCarrera();
                    fila[5] = entCon.getEntMateria();
                    fila[6] = entCon.getEntGrupoMate();
                    fila[7] = entCon.getEntHorario();
                    fila[8] = entCon.getEntGrupoLab();
                    tabla.addRow(fila);
                }
                this.jtbleEditarAlumnos.setModel(tabla);
            } else {
                JOptionPane.showMessageDialog(rootPane, "No se recuperaron datos de la base de datos", "CONFIRMACIÓN", JOptionPane.INFORMATION_MESSAGE);
            }
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(rootPane, ex.toString());
        }
    }

    //BLOQUEANDO CONTROLES
    public void BloquearControles() {

        this.jtxtID.setText("ID");
        this.jtxtCarnet.setText("Carnet");
        this.jtxtNombre.setText("Nombre");
        this.jtxtApellido.setText("Apellido");
        this.jcmbCarrera.setSelectedItem("Carrera");
        this.jcmbMateria.setSelectedItem("Materia");
        this.jcmbGrupoClase.setSelectedItem("Grupo Clase");
        this.jcmbHorario.setSelectedItem("Horario");
        this.jcmbGrupoLab.setSelectedItem("GrupoLab");


        this.jtxtID.setEnabled(false);
        this.jtxtCarnet.setEnabled(false);
        this.jtxtNombre.setEnabled(false);
        this.jtxtApellido.setEnabled(false);
        this.jcmbCarrera.setEnabled(false);
        this.jcmbMateria.setEnabled(false);
        this.jcmbGrupoClase.setEnabled(false);
        this.jcmbHorario.setEnabled(false);
        this.jcmbGrupoLab.setEnabled(false);

    }

    public void HabilitarControles() {

        this.jtxtID.setEnabled(false);
        this.jtxtCarnet.setEnabled(true);
        this.jtxtNombre.setEnabled(true);
        this.jtxtApellido.setEnabled(true);
        this.jcmbCarrera.setEnabled(true);
        this.jcmbMateria.setEnabled(true);
        this.jcmbGrupoClase.setEnabled(true);
        this.jcmbHorario.setEnabled(true);
        this.jcmbGrupoLab.setEnabled(true);

    }

    public void CargandoComboBox() {

        entHora = null;
        entMate = null;
        entGrupo = null;
        entCarre = null;


        try {

            //HORARIO
            arryHora = new ArrayList();
            hora = new Horario();
            arryHora = hora.MostrarCatalagoHorarios();
            JList list_1 = new JList();
            DefaultListModel listModel_1 = new DefaultListModel();
            listModel_1.addElement("Horarios");
            if (arryHora != null) {
                for (int i = 0; i < arryHora.size(); i++) {
                    EntityHorario entHora = (EntityHorario) arryHora.get(i);
                    listModel_1.addElement(entHora.getHorario());
                }
            } else {
                JOptionPane.showMessageDialog(rootPane, "No se recuperaron datos de la tabla Autor", "CONFIRMACIÓN", JOptionPane.INFORMATION_MESSAGE);
            }
            list_1.setModel(listModel_1);
            this.jcmbHorario.setModel(new DefaultComboBoxModel(listModel_1.toArray()));


            //Carrera
            arryCarre = new ArrayList();
            carre = new Carrera();
            arryCarre = carre.MostrarCarrera();
            JList jlist1 = new JList();
            DefaultListModel listModel1 = new DefaultListModel();
            listModel1.addElement("Carrera");
            if (arryCarre != null) {
                for (int i = 0; i < arryCarre.size(); i++) {
                    EntityCarrera entCarre = (EntityCarrera) arryCarre.get(i);
                    listModel1.addElement(entCarre.getNombre_carrera());
                }
            } else {
                JOptionPane.showMessageDialog(rootPane, "No se recuperaron datos de la tabla Carrera", "CONFIRMACIÓN", JOptionPane.INFORMATION_MESSAGE);

            }
            jlist1.setModel(listModel1);
            this.jcmbCarrera.setModel(new DefaultComboBoxModel(listModel1.toArray()));



            //GRUPO Clase
            arryGrupoMate = new ArrayList();
            gru = new Grupo();
            arryGrupoMate = gru.MostrarGrupos();
            JList list2 = new JList();
            DefaultListModel listModel2 = new DefaultListModel();
            listModel2.addElement("Grupo Clase");
            if (arryGrupoMate != null) {
                for (int i = 0; i < arryGrupoMate.size(); i++) {
                    EntityGrupo entGrupo = (EntityGrupo) arryGrupoMate.get(i);
                    listModel2.addElement(entGrupo.getGrupo());
                }

            } else {
                JOptionPane.showMessageDialog(rootPane, "No se recuperaron datos de la tabla Grupo", "CONFIRMACIÓN", JOptionPane.INFORMATION_MESSAGE);

            }
            list2.setModel(listModel2);
            this.jcmbGrupoClase.setModel(new DefaultComboBoxModel(listModel2.toArray()));

            //GRUPO LAB
            arryGrupoLab = new ArrayList();
            gru = new Grupo();
            arryGrupoLab = gru.MostrarGrupos();
            JList list3 = new JList();
            DefaultListModel listModel3 = new DefaultListModel();
            listModel3.addElement("Grupos Lab");
            if (arryGrupoLab != null) {
                for (int i = 0; i < arryGrupoLab.size(); i++) {
                    EntityGrupo entGrupo = (EntityGrupo) arryGrupoLab.get(i);
                    listModel3.addElement(entGrupo.getGrupo());
                }

            } else {
                JOptionPane.showMessageDialog(rootPane, "No se recuperaron datos de la tabla Grupo", "CONFIRMACIÓN", JOptionPane.INFORMATION_MESSAGE);

            }
            list3.setModel(listModel3);
            this.jcmbGrupoLab.setModel(new DefaultComboBoxModel(listModel3.toArray()));


            //MATERIA
            arryMate = new ArrayList();
            mate = new Materia();
            arryMate = mate.MostrarMaterias();
            JList list4 = new JList();
            DefaultListModel listModel4 = new DefaultListModel();
            listModel4.addElement("Materia");
            if (arryMate != null) {
                for (int i = 0; i < arryMate.size(); i++) {
                    EntityMateria entMate = (EntityMateria) arryMate.get(i);
                    listModel4.addElement(entMate.getCodigo_asignatura());
                }
            } else {
                JOptionPane.showMessageDialog(rootPane, "No se recuperaron datos de la tabla Materia", "CONFIRMACIÓN", JOptionPane.INFORMATION_MESSAGE);

            }
            list4.setModel(listModel4);
            this.jcmbMateria.setModel(new DefaultComboBoxModel(listModel4.toArray()));

        } catch (Exception ex) {
            System.out.println(ex.toString());
        }

    }
    
     public void cargarComboboxPlan() {
        
        ArrayList arryPlan = new ArrayList();
        pla = new Plan();
        arryPlan = pla.MostrarPlan();
        JList list_rad = new JList();
        DefaultListModel listModel_rad = new DefaultListModel();
        
        listModel_rad.addElement("Seleccione");
        if (arryPlan != null) {
            for (int i = 0; i < arryPlan.size(); i++) {
                entPla = (EntityPlan) arryPlan.get(i);
                listModel_rad.addElement(entPla.getNombre_plan());
            }
        } else {
            JOptionPane.showMessageDialog(rootPane, "No se recuperaron datos de la tabla Materia", "CONFIRMACIÓN", JOptionPane.INFORMATION_MESSAGE);
        }
        list_rad.setModel(listModel_rad);

        //seteando dos combos con los planes

        this.jcmbPlan.setModel(new DefaultComboBoxModel(listModel_rad.toArray()));
        this.jcmbPlan.setSelectedIndex(0);
        
     }
    
    public void BusquedasJTabla(String datos,int id_materia){
        DefaultTableModel tabla;
        Object[] fila = new Object[9];
        try {        
            //Encabezados de la tabla
            String[] columName = {"ID", "Carnet", "Nombre", "Apellido", "Carrera", "Materia", "Grupo Clase", "Horario Lab", "Grupo Lab"};
            // Agregamos los encabezados al modelo DafultTableModel
            tabla = new DefaultTableModel(null, columName);
            // Recuperamos el ArrayList de la tabla y populamos el ArrayList del formulario
            arryTable = new ArrayList();
            detal = new DetalleAlumno();
            EntityConsultaIntro entCon = new EntityConsultaIntro();
            arryTable = detal.BuscarAlumnosIntro(datos,id_materia);
            
            if (arryTable != null) {
                // Populamos el modelo con el arrayLiist de la clase Libros
                for(int i = 0; i < arryTable.size(); i++){
                    entCon = (EntityConsultaIntro) arryTable.get(i);
                    fila[0] = entCon.getId_alumno();
                    fila[1] = entCon.getEntCarnet();
                    fila[2] = entCon.getEntnombre();
                    fila[3] = entCon.getEntApellido();
                    fila[4] = entCon.getEntCarrera();
                    fila[5] = entCon.getEntMateria();
                    fila[6] = entCon.getEntGrupoMate();
                    fila[7] = entCon.getEntHorario();
                    fila[8] = entCon.getEntGrupoLab();
                    tabla.addRow(fila);
                }
                // Agregamos el  modelo DafaultTableModel al control jTable
                this.jtbleEditarAlumnos.setModel(tabla);
            }else {
                JOptionPane.showMessageDialog(rootPane, "No se recuperaron datos de la base de datos", "CONFIRMACIÓN", JOptionPane.INFORMATION_MESSAGE);
            }
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(rootPane, ex.toString());
        } 
    }
    
    
    public void CargarComboBoxMateria2(int id_plan) {
        //CARGANDO COMBOBOX DE MATERIAS
        ArrayList arryRad = new ArrayList();
       
        
        mate= new Materia();
        arryRad = mate.MostrarMateriasPlan_U1(id_plan);
        JList list_rad = new JList();
        DefaultListModel listModel_rad = new DefaultListModel();
        listModel_rad.addElement("Seleccione");
        if (arryRad != null) {
            for (int i = 0; i < arryRad.size(); i++) {
                entMate = (EntityMateria) arryRad.get(i);
                listModel_rad.addElement(entMate.getCodigo_asignatura());
            }
        } else {
            JOptionPane.showMessageDialog(rootPane, "No se recuperaron datos de la tabla Materia", "CONFIRMACIÓN", JOptionPane.INFORMATION_MESSAGE);
        }
        list_rad.setModel(listModel_rad);
        this.jcmbMateria2.setModel(new DefaultComboBoxModel(listModel_rad.toArray()));
        this.jcmbMateria2.setSelectedIndex(0);
    }
    
    

    public frmEditarAlumnoIntroFisica() {
        initComponents();
        this.setTitle("Editar Alumnos");


        
        CargandoComboBox();
        BloquearControles();
        cargarComboboxPlan();



    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jtbleEditarAlumnos = new javax.swing.JTable();
        jbtnCargar = new javax.swing.JButton();
        jbtnBuscar = new javax.swing.JButton();
        jbtnGenerarTxt = new javax.swing.JButton();
        jtxtCarnet = new javax.swing.JTextField();
        jtxtNombre = new javax.swing.JTextField();
        jtxtApellido = new javax.swing.JTextField();
        jcmbCarrera = new javax.swing.JComboBox();
        jcmbMateria = new javax.swing.JComboBox();
        jcmbGrupoLab = new javax.swing.JComboBox();
        jcmbGrupoClase = new javax.swing.JComboBox();
        jcmbHorario = new javax.swing.JComboBox();
        jtxtID = new javax.swing.JTextField();
        btnEliminar = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jcmbPlan = new javax.swing.JComboBox();
        jLabel2 = new javax.swing.JLabel();
        jcmbMateria2 = new javax.swing.JComboBox();

        setClosable(true);
        setIconifiable(true);
        setMaximizable(true);
        setResizable(true);

        jtbleEditarAlumnos.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        jtbleEditarAlumnos.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jScrollPane1.setViewportView(jtbleEditarAlumnos);

        jbtnCargar.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N
        jbtnCargar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/proyecto/imagenes/cargar.png"))); // NOI18N
        jbtnCargar.setText("Cargar");
        jbtnCargar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jbtnCargarMouseClicked(evt);
            }
        });

        jbtnBuscar.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N
        jbtnBuscar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/proyecto/imagenes/buscar.png"))); // NOI18N
        jbtnBuscar.setText("Buscar");
        jbtnBuscar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jbtnBuscarMouseClicked(evt);
            }
        });

        jbtnGenerarTxt.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N
        jbtnGenerarTxt.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/proyecto/imagenes/generartxt.jpg"))); // NOI18N
        jbtnGenerarTxt.setText("Generar txt");
        jbtnGenerarTxt.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jbtnGenerarTxtMouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                jbtnGenerarTxtMouseEntered(evt);
            }
        });

        jtxtCarnet.setText("Carnet");

        jtxtNombre.setText("Nombre");

        jtxtApellido.setText("Apellido");

        jcmbCarrera.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Carrera" }));

        jcmbMateria.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Materia" }));

        jcmbGrupoLab.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Grupo Lab" }));

        jcmbGrupoClase.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Grupo Clase" }));

        jcmbHorario.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Horario" }));

        jtxtID.setText("ID");
        jtxtID.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtxtIDActionPerformed(evt);
            }
        });

        btnEliminar.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N
        btnEliminar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/proyecto/imagenes/images (2).jpg"))); // NOI18N
        btnEliminar.setText("Eliminar");
        btnEliminar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btnEliminarMouseClicked(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N
        jLabel1.setText("Plan:");

        jcmbPlan.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        jcmbPlan.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jcmbPlanItemStateChanged(evt);
            }
        });

        jLabel2.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N
        jLabel2.setText("Materia:");

        jcmbMateria2.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jcmbMateria2ItemStateChanged(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(30, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addGap(53, 53, 53)
                        .addComponent(jcmbPlan, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 1200, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addGap(29, 29, 29)
                        .addComponent(jcmbMateria2, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(74, 74, 74)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jtxtID, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jtxtCarnet, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jtxtNombre, javax.swing.GroupLayout.PREFERRED_SIZE, 215, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jtxtApellido, javax.swing.GroupLayout.PREFERRED_SIZE, 248, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(jcmbCarrera, javax.swing.GroupLayout.PREFERRED_SIZE, 279, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(jbtnBuscar, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(61, 61, 61)
                                    .addComponent(jbtnGenerarTxt)
                                    .addGap(42, 42, 42)
                                    .addComponent(btnEliminar))
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(jcmbMateria, javax.swing.GroupLayout.PREFERRED_SIZE, 240, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(27, 27, 27)
                                    .addComponent(jcmbGrupoClase, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(18, 18, 18)
                                    .addComponent(jcmbHorario, javax.swing.GroupLayout.PREFERRED_SIZE, 287, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(jcmbGrupoLab, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))))
                .addGap(31, 31, 31))
            .addGroup(layout.createSequentialGroup()
                .addGap(280, 280, 280)
                .addComponent(jbtnCargar, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(30, 30, 30)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel1)
                        .addComponent(jcmbPlan, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jtxtNombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jcmbCarrera, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jtxtApellido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jtxtCarnet, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jtxtID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(38, 38, 38)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jcmbMateria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jcmbGrupoClase, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jcmbHorario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jcmbMateria2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel2)
                            .addComponent(jcmbGrupoLab, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 105, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jbtnCargar, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jbtnBuscar, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jbtnGenerarTxt)
                    .addComponent(btnEliminar, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(39, 39, 39)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 358, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(26, 26, 26))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jbtnCargarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jbtnCargarMouseClicked
        // TODO add your handling code here:
        HabilitarControles();
        CargandoComboBox();

        int fila = this.jtbleEditarAlumnos.getSelectedRow();
        this.jtxtID.setText(String.valueOf(this.jtbleEditarAlumnos.getValueAt(fila, 0)));
        this.jtxtCarnet.setText(String.valueOf(this.jtbleEditarAlumnos.getValueAt(fila, 1)));
        this.jtxtNombre.setText(String.valueOf(this.jtbleEditarAlumnos.getValueAt(fila, 2)));
        this.jtxtApellido.setText(String.valueOf(this.jtbleEditarAlumnos.getValueAt(fila, 3)));
        this.jcmbCarrera.setSelectedItem(String.valueOf(this.jtbleEditarAlumnos.getValueAt(fila, 4)));
        this.jcmbMateria.setSelectedItem(String.valueOf(this.jtbleEditarAlumnos.getValueAt(fila, 5)));
        this.jcmbGrupoClase.setSelectedItem(this.jtbleEditarAlumnos.getValueAt(fila, 6));
        this.jcmbHorario.setSelectedItem(String.valueOf(this.jtbleEditarAlumnos.getValueAt(fila, 7)));
        this.jcmbGrupoLab.setSelectedItem(this.jtbleEditarAlumnos.getValueAt(fila, 8));
    }//GEN-LAST:event_jbtnCargarMouseClicked

    private void jtxtIDActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtxtIDActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jtxtIDActionPerformed

    private void jbtnBuscarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jbtnBuscarMouseClicked
        // TODO add your handling code here:
        String titulo = (String)JOptionPane.showInputDialog(rootPane, "Ingrese el Carnet, Nombre, Apellido u Horario", "Busqueda", JOptionPane.PLAIN_MESSAGE);
        BusquedasJTabla(titulo,id_materia);
    }//GEN-LAST:event_jbtnBuscarMouseClicked

    private void jbtnGenerarTxtMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jbtnGenerarTxtMouseEntered
        // TODO add your handling code here:
    }//GEN-LAST:event_jbtnGenerarTxtMouseEntered

    private void jbtnGenerarTxtMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jbtnGenerarTxtMouseClicked
        // TODO add your handling code here:
        String msj;
        msj = detal.generarTXT(this.arryTable);
        JOptionPane.showMessageDialog(rootPane, msj, "CONFIRMACIÓN", JOptionPane.INFORMATION_MESSAGE);
    }//GEN-LAST:event_jbtnGenerarTxtMouseClicked

    private void jcmbPlanItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jcmbPlanItemStateChanged
        ArrayList arryPlan = new ArrayList();
        
        pla = new Plan();
        arryPlan=pla.MostrarPlan();
        
        for (int i = 0; i < arryPlan.size(); i++) {
            entPla = (EntityPlan) arryPlan.get(i);
            if (this.jcmbPlan.getSelectedItem().equals(entPla.getNombre_plan())) {
                this.id_plan = entPla.getId_plan();
            }
        }
         
         CargarComboBoxMateria2(id_plan);
    }//GEN-LAST:event_jcmbPlanItemStateChanged

    private void jcmbMateria2ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jcmbMateria2ItemStateChanged
        ArrayList arryMateria2 = new ArrayList();
        
        mate = new Materia();
        arryMateria2=mate.MostrarMateriasPlan_U1(id_plan);
        
        for (int i = 0; i < arryMateria2.size(); i++) {
            entMate = (EntityMateria) arryMateria2.get(i);
            if (this.jcmbMateria2.getSelectedItem().equals(entMate.getCodigo_asignatura())) {
                this.id_materia = entMate.getId_materia();
            }
        }
        
        PopulatTabla(id_materia);
    }//GEN-LAST:event_jcmbMateria2ItemStateChanged

    private void btnEliminarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnEliminarMouseClicked
        
        int id_alumno=Integer.parseInt(this.jtxtID.getText());
        
        detal=new DetalleAlumno();
        String msj=detal.BorrarDetalle_Al(id_alumno);
        JOptionPane.showMessageDialog(rootPane,msj,"CONFIRMACIÓN",JOptionPane.INFORMATION_MESSAGE);
        PopulatTabla(id_materia);
    }//GEN-LAST:event_btnEliminarMouseClicked

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnEliminar;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JButton jbtnBuscar;
    private javax.swing.JButton jbtnCargar;
    private javax.swing.JButton jbtnGenerarTxt;
    private javax.swing.JComboBox jcmbCarrera;
    private javax.swing.JComboBox jcmbGrupoClase;
    private javax.swing.JComboBox jcmbGrupoLab;
    private javax.swing.JComboBox jcmbHorario;
    private javax.swing.JComboBox jcmbMateria;
    private javax.swing.JComboBox jcmbMateria2;
    private javax.swing.JComboBox jcmbPlan;
    private javax.swing.JTable jtbleEditarAlumnos;
    private javax.swing.JTextField jtxtApellido;
    private javax.swing.JTextField jtxtCarnet;
    private javax.swing.JTextField jtxtID;
    private javax.swing.JTextField jtxtNombre;
    // End of variables declaration//GEN-END:variables
}
